#/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'


import maya.cmds as cmds
import maya.mel as mel

class Validation(object):

    name = u"Lambert1 | 默认材质检查"
    dataDict = dict

    def execute(self):
        self.dataDict = {}
        shaderList = cmds.ls(mat=1)
        defaultShaderList = ['lambert1', 'particleCloud1']
        if defaultShaderList != shaderList:
            for shader in shaderList:
                if shader not in defaultShaderList:
                    cmds.hyperShade(objects=shader)
                    self.dataDict[shader] = cmds.ls(sl=1)
        return self.dataDict

    def correct(self):
        try:
            cmds.sets(cmds.ls(type='mesh'), forceElement='initialShadingGroup', edit=True)
            mel.eval('MLdeleteUnused()')
        except:pass

    def search(self, obj):
        cmds.hyperShade(objects=obj)

